<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-02 19:42:06
 * @LastEditTime: 2023-11-12 14:13:32
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Repositories;

use App\Models\Employee;
use App\Models\User;

/**
 * @property Employee $model
 * @property User $user
 * @author sunkaiyuan
 */
class EmployeeRepository extends Repositories
    {
    protected $relation_models = [
        'department',
        'attachments',
        'education',
        'contactor_relation',
        'marriage',
        'shift',
        'position'
    ];
    public function __construct(Employee $model)
        {
        $this->model = $model;
        }
    public function fuzzySearch($value)
        {
        $value = trim($value);
        $this->where(function ($query) use ($value)
            {
            $query->orWhere("name", "like", "%{$value}%");
            $query->orWhere("code", "like", "%{$value}%");
            });
        }
    }
